package com.itboye.jmsfhz.app.adapter;

import java.text.SimpleDateFormat;

import com.itboye.config.GlobalConfig;
import com.itboye.core.utils.XImageLoader;
import com.itboye.jmsfhz.R;
import com.itboye.jmsfhz.data.model.RecruitBean;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/***
 * 
 * @author 就业
 * 
 */
public class EmploymentAdapter extends BaseAdapter {

	Context context;
	RecruitBean list;

	public EmploymentAdapter(Context context,RecruitBean list) {
		this.context = context;
		this.list=list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.getResult()==null?0:list.getResult().size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.getResult().get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@SuppressLint("SimpleDateFormat") @Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHouder houder;
		if (convertView == null) {
			houder=new ViewHouder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.item_emploment, null);
			houder.imgMessge=(ImageView) convertView.findViewById(R.id.imgMessge);
			houder.tvcompany=(TextView) convertView.findViewById(R.id.tvcompany);
			houder.tvAddree=(TextView) convertView.findViewById(R.id.tvAddree);
			houder.tvEmplomenttionTime=(TextView) convertView.findViewById(R.id.tvEmplomenttionTime);
			houder.imgauthentiaion=(ImageView) convertView.findViewById(R.id.imgauthentiaion);
			convertView.setTag(houder);
		}else{
			houder=(ViewHouder) convertView.getTag();
		}
		if(list.getResult().get(position).getIs_auth_e().equals("0")){
			houder.imgauthentiaion.setVisibility(View.GONE);
		}else if(list.getResult().get(position).getIs_auth_e().equals("1")){
			houder.imgauthentiaion.setVisibility(View.VISIBLE);
		}
		houder.tvcompany.setText(list.getResult().get(position).getTitle());
		houder.tvAddree.setText(list.getResult().get(position).getAddress());
		System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>"+list.getResult().get(position).getAddress());
		houder.tvEmplomenttionTime.setText(new SimpleDateFormat("yyyy-MM-dd").format(Long
				.parseLong(list.getResult().get(position).getUpdate_time())*1000));
		XImageLoader.load(GlobalConfig.JIUYE+list.getResult().get(position).getLogo(), houder.imgMessge);
		
		
		return convertView;
	}
	class ViewHouder{
		ImageView imgMessge,imgauthentiaion;
		TextView tvcompany;
		TextView tvAddree;
		TextView tvEmplomenttionTime;
	}

}
